package util;

import java.util.HashMap;
import java.util.Map;

public class ResponseUtil {
    // 成功响应
    public static Map<String, Object> success(String message) {
        Map<String, Object> response = new HashMap<>();
        response.put("success", true);
        response.put("message", message);
        return response;
    }

    public static Map<String, Object> success(String message, Object data) {
        Map<String, Object> response = success(message);
        response.put("data", data);
        return response;
    }

    public static Map<String, Object> success(Object data) {
        Map<String, Object> response = new HashMap<>();
        response.put("success", true);
        response.put("data", data);
        return response;
    }

    // 错误响应
    public static Map<String, Object> error(String message) {
        Map<String, Object> response = new HashMap<>();
        response.put("success", false);
        response.put("message", message);
        return response;
    }

    public static Map<String, Object> error(String message, int status) {
        Map<String, Object> response = new HashMap<>();
        response.put("success", false);
        response.put("message", message);
        response.put("status", status);
        return response;
    }

    // 未登录响应
    public static Map<String, Object> unauthorized() {
        return error("未登录", 401);
    }

    // 无权限响应
    public static Map<String, Object> forbidden() {
        return error("无权限执行此操作", 403);
    }
}
